﻿@{
    Layout = "~/Views/Shared/_LayoutForEUI.cshtml";
    var listColumns = ViewBag.Columns as List<SGArchiveSystem7x.Models.CColumnsModel>;
    var listMJ = ViewBag.MJ as List<SGArchiveSystem7x.Models.CComboboxModel>;
}
<table id="Role_Index_grid" class="easyui-datagrid" style="width:100%;" title="@ViewBag.Text0" data-options="
       rownumbers:true,
       singleSelect:true,
       autoRowHeight:false,
       pagination:true,
       fitColumns:true,
       fit:true,
       striped:true,
       checkOnSelect:false,
       selectOnCheck:false,
       toolbar:'#Role_Index_tb',
       collapsible:false,
       pageSize: @SGArchiveSystem7x.Models.CCommonsModels.PageSize,
       pageList:[10,15,20]">
    <thead frozen="true">
        <tr>
            @{foreach (var c in listColumns)
                {
                    if (c.Frozen)
                    {
                        <th field="@c.FieldValue" width="@c.Len" align="center" formatter="@c.Formate">@c.FieldText</th>
                    }

                }
            }
        </tr>
    </thead>
    <thead>
        <tr>
            @{foreach (var c in listColumns)
                {
                    if (!c.Frozen)
                    {
                        <th field="@c.FieldValue" width="@c.Len" align="center" formatter="@c.Formate">@c.FieldText</th>
                    }

                }
            }
        </tr>
    </thead>
</table>
<div id="Role_Index_tb" style="padding:2px 5px;">
    <input type="text" class="easyui-textbox" label="@ViewBag.Text01:" labelwidth="80px" style="width:200px" id="Role_Index_txtRoleName" />
    <select class="easyui-combobox" label="@ViewBag.Text02:" labelwidth="80px" style="width:200px" id="Role_Index_cmbRoleStatus" editable="false" panelHeight="auto">
        @{ 
            if(SGArchiveSystem7x.Models.Language._nowLanguage == SGArchiveSystem7xDB._VersionLanguage._Chs)
            {
                <option value="-1">全部</option>
                <option value="0">停用</option>
                <option value="1">启用</option>
            }
            else
            {
                <option value="-1">ALL</option>
                <option value="0">Stop</option>
                <option value="1">Enable</option>
            }
        }
        
    </select>
    <a href="javascript:void(0);" id="Role_Index_btnQuery" class="easyui-linkbutton button-blue" iconCls="icon-search" onclick="query()" style="width:110px;height:30px;">@ViewBag.Text1</a>
    <a href="javascript:void(0);" id="Role_Index_btnAdd" class="easyui-linkbutton button-blue" iconCls="icon-ok" onclick="Add_Role()" style="width:110px;height:30px;">@ViewBag.Text2</a>
</div>
<div id="Role_Index_winRoleInfo" class="easyui-window" title="@ViewBag.Text6" data-options="modal:true,closed:true,iconCls:'icon-save'" minimizable="false" maximizable="false" resizable="false" collapsible="false"
     style="width:560px;height:450px;padding:10px">
    <div class="easyui-layout" data-options="fit:true">
        <div data-options="region:'center'" style="padding:10px;border:0px">
            <iframe id="Role_Index_frm" name="Role_Index_frm" src="" width="100%" height="420px" frameborder="0" ></iframe>
        </div>
    
    </div>
</div>  
<script>
    var arrayMJ = @Html.Raw(Json.Encode(listMJ));
    //alert(arrayMJ);
    $(document).ready(function () {
        $('#Role_Index_grid').datagrid({
            url: '/Role/Get_ajaxRoleList?name=&status=-1',
            singleSelect: true,
            method: 'post',
            onLoadSuccess: function (data) {
                $('.pagination-page-list').hide();
            }
        });
    });

    ///快速查询
    function query() {
        var name = $('#Role_Index_txtRoleName').val();
        var status = $('#Role_Index_cmbRoleStatus').combobox('getValue');
        $('#Role_Index_grid').datagrid({
            url: '/Role/Get_ajaxRoleList?name=' + name + '&status=' + status,
            singleSelect: true,
            method: 'post'
        });

        InitPagenation();
        $('#Role_Index_grid').datagrid('options').pageNumber = 1;
        return;
    }


    ///初始化分页
    function InitPagenation() {
        //设置分页控件
        var p = $('#Role_Index_grid').datagrid('getPager');
        $(p).pagination({
            onSelectPage: function (pageNumber, pageSize) {
                QueryPager(pageNumber, pageSize);
            }
        });
    }

    ///刷新之后，把存放数据清除
    function UpdateList() {
        closeWin();
        QueryPager($('#Role_Index_grid').datagrid('options').pageNumber, $('#Role_Index_grid').datagrid('options').pageSize);
    }

    function closeWin() {
        document.getElementById('Role_Index_frm').src = '';
        $('#Role_Index_winRoleInfo').window('close');
    }

    ///分页查询
    function QueryPager(num, size) {
        $('#Role_Index_grid').datagrid('options').url= '/Role/Get_ajaxRoleListPager?num=' + num + '&size=' + size;
        $('#Role_Index_grid').datagrid('reload');
        $('#Role_Index_grid').datagrid('options').pageNumber = num;
        $('#Role_Index_grid').datagrid('options').pageSize = size;
        return;
    }


    function Add_Role() {
        document.getElementById('Role_Index_frm').src = "/Role/RoleInfo?id=0";
        $('#Role_Index_winRoleInfo').window('open');
    }

    function Modify_Role(id) {
        document.getElementById('Role_Index_frm').src = "/Role/RoleInfo?id=" + id;
        $('#Role_Index_winRoleInfo').window('open');
    }

    function formatStatus(value, row) {
        if (value == '0')
            return "<span style='color:red'>" + '@ViewBag.Text4'  + "</span>";
        else
            return "<span style='color:blue'>" + '@ViewBag.Text5' + "</span>";
    }

    function formatEdit(value, row) {
        return "<a href='javascript:void(0)' onclick='Modify_Role(" + value + ")'><img src='../Content/images/edit.png'></img>" + '@ViewBag.Text3' + "</a>";
    }

    function formatMJ(value, row) {
        for (var i = 0; i < arrayMJ.length; i++) {
            if (arrayMJ[i].ID == value) {
                return "<span style='color:blue'>" +  arrayMJ[i].Text  + "</span>";
            }
        }
    }

    function save() {
        Role_Index_frm.window.save();
    }
</script>

